/**
 * 财务管理复核到账控制器
 */
import './index.less'
import $_fn from '~plugins'
export default ['$scope','$rootScope','$location','$ui','http','$state',function($scope,$rootScope,$location,$ui,http,$state) {
    $scope.$_fn = $_fn
	//四级按钮
	$scope.tabMenu = $_fn.getCurrMenu($location.path())
    console.log($scope.tabMenu)
    $scope.subMenu = $scope.tabMenu.children[0].children
    console.log($scope.subMenu)
	$scope.page ={}
	//四级按钮页面跳转方法
	$scope.operation = function (path,item) {
		console.log('111')
        var _path = path.split('@')
        let params = JSON.stringify(item)
        if(_path[0] == 'link'){
            console.log(path)
            $state.go(_path[1],item)
        }
        if(_path[0] == 'alert'){
            $ui.modal({content:"<"+_path[1]+" params="+params+"></"+_path[1]+">"})
        }
    }
	//初始化对象
	$scope.params={
		pageNum:1,
		loan_type:-1,
		at_id:-1,
		type:-1,
		status:-1
	}
	$scope.param1={
		status:0
	}
    $scope.params = $location.search()
	//获取数据的函数
    $scope.getDada = function(page, params){
        params.pageNum = page
        http.post('checkAccountList.do',params,function (data) {
            var _data = data.data
            $scope.page.pageNum =  $scope.params.pageNum
            $scope.page.pageSize = _data.pageSize
            $scope.page.total = _data.total
            if(data.errcode > 0){
                $scope.$apply(function () {
                    $scope.param1.dataList = data.data.list;
                    $scope.param1.orderList = data.data;
                    //$scope.param1.stateList = data.data.stateList;//状态
                    //$scope.param1.applyTermList = data.data.applyTermList;//期限
                })
            }else{
            	$ui.toast({
					text:data.errmsg,
					type:'warning'
				})
            }
        },function(){
            //报错时
            $scope.isData = true
            $scope.$apply()
        })
    }
	$scope.getDada(1, $scope.params)
    $scope.select = [{name:'以租代购',value:1},{name:'信贷方式',value:2}]

    //搜索
    $scope.searchHandle = function () {
      if($scope.params.keyword && $scope.params.type==-1){
        $scope.err.type = true
        $scope.errorToast('左侧字段没有选择')
        return
      }
      $location.search($scope.params)
      $scope.getDada(1,$scope.params)
    }
}]
